<?php
namespace app\admin\model;
use think\Model;
use think\db;
class Rate extends model{
	function findandicap($andicap=1){
		$res = $this->where("andicap",$andicap)->select();
		return $res;
	}
	function findes($andicap=1,$bet,$colums=1){
		// 对应目录的赔率
		$result = $this->where(['andicap'=>$andicap,'bet'=>$bet,"colums"=>$colums])->select();
		return $result;
	}
	function findrate($andicap=1,$bet){
		$res = db("rate")->where(["andicap"=>$andicap,"bet"=>$bet])->select();
		return $res;
	}
	function findrateA(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>1,"colums"=>1])->select();
		return $res;
	}
	function findrate18_50(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>9,"colums"=>1])->where('bets',">",18)->select();
		return $res;
	}
	function findrates(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>1,"colums"=>1])->where('bets',"<",50)->select();
		return $res;
	}
	function finds($bet){
		$res = db("rate")->where(["andicap"=>1,"bet"=>$bet])->select();
		return $res;
	}
	function finds12(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>12,"colums"=>1])->select();
		return $res;
	}
	function findrateB(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>1,"colums"=>2])->select();
		return $res;
	}
	function findTemaRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>1,"colums"=>1])->select();
		return $res;
	}
	function findsZhengmaRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>2])->select();
		return $res;
	}
	function findsZhengmaTeRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>3])->select();
		return $res;
	}
	function findsZm1to6Rate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>4])->select();
		return $res;
	}
	function findsBanBoRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>8])->select();
		return $res;
	}
	function findssevenRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>9])->select();
		return $res;
	}
	function findsTemaSXTWRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>6])->select();
		return $res;
	}
	function findsZTDXXduoxiaoRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>12])->select();
		return $res;
	}
	function findsweishulianRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>11])->select();
		return $res;
	}
	function findsZMGGRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>5])->select();
		return $res;
	}
	function findsSQZRate(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>7])->select();
		return $res;
	}
	function findswbzhong(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>14])->select();
		return $res;
	}
	function findsanzhongyi(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>15])->select();
		return $res;
	}
	function findsyixiao(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>13])->select();
		return $res;		
	}
	function findszhengxiao(){
		$res = db("rate")->where(["andicap"=>1,"bet"=>9])->select();
		return $res;
	}
	function findratepancha($andicap,$bet,$colums,$bets){
		$data = getpancha($andicap,$bet,$colums,$bets);
		$data = json_decode($data,true);
		$pancha = model('pancha')->findandicap($data["id"],$data['n']);
		$res = db('rate')->where(['bet'=>$bet,'colums'=>$colums,'bets'=>$bets])->find();
		$res['ra'] += $pancha;
		return $res['ra']; 
	}
}